<template>
	<van-grid square :border="false">
		<van-grid-item v-for="(l,index) in list" :key="index" :icon="getimg(l)" :text="l.name" @click="toPage(l)" />
		<van-grid-item :icon="specialIcon" :text="special.name" @click="toPage(special)" />
	</van-grid>
</template>

<script>
	import icon1 from "@/assets/img/home.png"
	import icon2 from "@/assets/img/notice.png"
	import icon3 from "@/assets/img/watch.png"
	import icon4 from "@/assets/img/hudong.png"
	import icon5 from "@/assets/img/ask.png"
	import icon6 from "@/assets/img/diaocha.png"
	import icon7 from "@/assets/img/fazhi.png"
	import icon8 from "@/assets/img/gongyi.png"
	import icon9 from "@/assets/img/about.png"
	import icon10 from "@/assets/img/liuyan.png"
	import icon11 from "@/assets/img/weiquan.png"
	import icon12 from "@/assets/img/zhuanti.png"
	export default {
		name: "Card",
		components: {

		},
		data() {
			return {
				specialIcon:icon12,
				iconList: [{
						icon: icon1,
						text: '查找家园',
						url:'/classify?title=查找家园'
					},
					{
						icon: icon2,
						text: '服务公告',
						url:'/classify?title=服务公告'
					},
					{
						icon: icon3,
						text: '家园见闻',
						url:'/classify?title=家园见闻'
					},
					{
						icon: icon4,
						text: '城乡互动',
						url:'/classify?title=城乡互动'
					},
					{
						icon: icon5,
						text: '卜咚问问',
						url:'/classify?title=卜咚问问'
					},
					{
						icon: icon6,
						text: '家园调查',
						url:'/classify?title=家园调查'
					},
					{
						icon: icon7,
						text: '法治道德',
						url:'/classify?title=法治道德'
					},
					{
						icon: icon7,
						text: '法制道德',
						url:'/classify?title=法制道德'
					},
					{
						icon: icon8,
						text: '公益帮助',
						url:'/classify?title=查找家园'
					},
					{
						icon: icon9,
						text: '关于我们',
						url:'/classify?title=关于我们'
					},
					{
						icon: icon10,
						text: '建议留言',
						url:'/classify?title=建议留言'
					},
					{
						icon: icon11,
						text: '举报维权',
						url:'/classify?title=举报维权'
					},
					{
						icon: icon12,
						text: '专题专栏',
						url:'/classify?title=专题专栏'
					}
				],
				list:[],
				special:{}
			}
		},
		mounted() {
			this.$api.home.nav({type:this.$localStorage.get("siteType")||1,pid:0}).then(res => {
				// 执行某些操作
				if (res.code == 1) {
					this.list = res.data
					this.$emit("saveInfo",res.data)
					this.list.forEach(item=>{
						if(item.name == "卜咚问问"){
							this.$localStorage.set("askData",item)
						}else if(item.name=='政府信息'){
							this.$emit("getInfo",item)
						}else if(item.name=='政府管理'){
							this.$emit("getInfo",item)
						}else if(item.name=='跑腿办事'){
							this.$emit("getpaotui",item)
						}else if(item.name=='便民服务'){
							this.$emit("getConvenient",item)
						}else if(item.name=='家园购物'){
							this.$emit("getBuy",item)
						}
					})
				}
			
			})
			this.$api.home.special({site_id:this.$localStorage.get("site_id")}).then(res => {
				// 执行某些操作
				if (res.code == 1) {
					this.special = res.data
					this.$set(this.special,"special",1)
					this.$emit("getSpecial",res.data)
				}
			
			})
		},
		filters:{
			
		},
		methods:{
			getimg:function(val){
				let dd = ''
				this.iconList.forEach(item=>{
					if(item.text == val.name ){
						dd = item.icon
					}
				})
				return dd
			},
			toPage(l){
				this.$localStorage.set('firstLevel', l)
				this.$router.push({path:'/classify'})
			}
		}


	}
</script>

<style lang="less">
	.van-grid{
		background: #fff;
	}
</style>
